// 提交链接：https://leetcode.cn/problems/container-with-most-water/
// lc11. 盛最多水的容器
// 完成日期：2024/9/9
// c++ 双指针

class Solution {
public:
    int maxArea(vector<int>& height) {
        int left = 0, right = height.size() - 1;
        int ans = 0;
        
        while (left < right)
        {
            int h = min(height[left], height[right]);
            int w = right - left;
            ans = max(ans, h * w);
            
            if (height[left] < height[right])  ++left;
            else   --right;
        }
        return ans;
    }
};
